# -*- coding: utf-8 -*-
# @Time    : 2020-10-22 10:29
# @Author  : Leo
# @FileName: login_handler.py
# @Software: PyCharm
import json
import tornado.web
from modules.user.user_manage import UserManager
from handlers.base_handler import BaseHandler

# class BaseHandler(tornado.web.RequestHandler):
#     #blog.csdn.net/moshowgame 解决跨域问题
#     def set_default_headers(self):
#         self.set_header('Access-Control-Allow-Origin', '*')
#         self.set_header('Access-Control-Allow-Headers', '*')
#         self.set_header('Access-Control-Max-Age', 1000)
#         #self.set_header('Content-type', 'application/json')
#         self.set_header('Access-Control-Allow-Methods', 'POST, GET, OPTIONS')
#         self.set_header('Access-Control-Allow-Headers',#'*')
#                         'authorization, Authorization, Content-Type, Access-Control-Allow-Origin, Access-Control-Allow-Headers, X-Requested-By, Access-Control-Allow-Methods')
#
#     def options(self):
#         pass


class LoginHandler(BaseHandler):
    '''
    处理登陆请求
    '''



    def post(self):
        '''
        @return:
        '''
        data = json.loads(self.request.body)
        self.write(UserManager().login(loginName=data['loginName'],
                            password=data['password']))

    def get(self):
        self.write("sucess")